#pragma once
#include "bytes_buffer.hpp"

// Kinect DK
#include <k4a/k4a.hpp>

static const int kBufferDefaultSize = 10 * 1024 * 1024;
static const int kImageType_rgb = 1;
static const int kImageType_depth = 2;
static const int kImageType_ir = 3;
class RecordImage
{
public:
    RecordImage()
        :_buffer1(kBufferDefaultSize),
        _buffer2(kBufferDefaultSize)
    {
    }

    RecordImage(const char* fileName) 
        :_buffer1(kBufferDefaultSize),
        _buffer2(kBufferDefaultSize),
        _fileName(fileName)
    {
    }

    ~RecordImage() {}
    void compress(const char *in_buf, uint32_t in_buf_size, BytesBuffer* out);
    void compress(BytesBuffer* in, BytesBuffer* out);
    void decompress(std::vector<char>& in_vec, BytesBuffer* out);
    void decompress(BytesBuffer* buffer, BytesBuffer* out);

    void compressAndWriteImageData(k4a::image& img);
    void writeToFile();
    
    void showDebugImage(BytesBuffer* p, int imageType = kImageType_rgb);
private:

    BytesBuffer _buffer1;
    BytesBuffer _buffer2;
    BytesBuffer* _curBuf = nullptr;
    std::string _fileName;
};

